package com.ruoyi.business.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.potentialCustomerMapper;
import com.ruoyi.business.domain.potentialCustomer;
import com.ruoyi.business.service.IpotentialCustomerService;
import com.ruoyi.common.core.text.Convert;

/**
 * 潜在客户Service业务层处理
 * 
 * @author wolfcode
 * @date 2021-07-26
 */
@Service
public class potentialCustomerServiceImpl implements IpotentialCustomerService 
{
    @Autowired
    private potentialCustomerMapper potentialCustomerMapper;

    /**
     * 查询潜在客户
     * 
     * @param id 潜在客户ID
     * @return 潜在客户
     */
    @Override
    public potentialCustomer selectpotentialCustomerById(Long id)
    {
        return potentialCustomerMapper.selectpotentialCustomerById(id);
    }

    /**
     * 查询潜在客户列表
     * 
     * @param potentialCustomer 潜在客户
     * @return 潜在客户
     */
    @Override
    public List<potentialCustomer> selectpotentialCustomerList(potentialCustomer potentialCustomer)
    {
        return potentialCustomerMapper.selectpotentialCustomerList(potentialCustomer);
    }

    /**
     * 新增潜在客户
     * 
     * @param potentialCustomer 潜在客户
     * @return 结果
     */
    @Override
    public int insertpotentialCustomer(potentialCustomer potentialCustomer)
    {
        int count = potentialCustomerMapper.selectCountByPhone(potentialCustomer.getPhone());
        //判断是否拥有
        if (count > 0){
            return 0;
        }else {
            potentialCustomer.setCreateTime(DateUtils.getNowDate());
            return potentialCustomerMapper.insertpotentialCustomer(potentialCustomer);
        }
    }

    /**
     * 修改潜在客户
     * 
     * @param potentialCustomer 潜在客户
     * @return 结果
     */
    @Override
    public int updatepotentialCustomer(potentialCustomer potentialCustomer)
    {
        return potentialCustomerMapper.updatepotentialCustomer(potentialCustomer);
    }

    /**
     * 删除潜在客户对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deletepotentialCustomerByIds(String ids)
    {
        return potentialCustomerMapper.deletepotentialCustomerByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除潜在客户信息
     * 
     * @param id 潜在客户ID
     * @return 结果
     */
    @Override
    public int deletepotentialCustomerById(Long id)
    {
        return potentialCustomerMapper.deletepotentialCustomerById(id);
    }

    @Override
    public List<potentialCustomer> selectpotentialCustomerListById(potentialCustomer  potentialCustomer) {
        return potentialCustomerMapper.selectpotentialCustomerListById(potentialCustomer);
    }
}
